package vapu.examples;
import im.composer.audioservers.adapter.CallableAudioServer;
import im.composer.media.sound.render.SourcePlayer;
import im.composer.midi.MidiCable;
import im.composer.vapu.adapter.GervillSynth;

import java.util.Arrays;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.jaudiolibs.audioservers.AudioConfiguration;
import org.jaudiolibs.audioservers.AudioServer;
import org.jaudiolibs.audioservers.javasound.JSAudioServerProvider;

import themidibus.MidiBus;

public class SynthExample {

	public static void main(String[] args) throws Throwable {
		System.out.println(Arrays.toString(MidiBus.availableInputs()));
		AudioConfiguration conf = new AudioConfiguration(48000, 0, 2, 512, true);
		GervillSynth synth = new GervillSynth();
		SourcePlayer player = new SourcePlayer();
		player.addSource(synth);
		MidiCable cable = new MidiCable("iCON iKEY V1.02",synth);
		AudioServer server = new JSAudioServerProvider().createServer(conf, player);
		ExecutorService exec = Executors.newCachedThreadPool();
		CallableAudioServer.submit(exec, server);
		System.out.println("ready!");
	}

}
